//
//  selfSendRedPacketViewController.m
//  WZEfengAndEtong
//
//  Created by 李旭 on 16/9/27.
//  Copyright © 2016年 wanzhao. All rights reserved.
//

#import "selfSendRedPacketViewController.h"
#import "Masonry.h"
#import "UIImageView+WebCache.h"
#import "CContactMgr.h"
#import "CContactModel.h"
#import "CMessageMgr.h"
#import "CMessageModel.h"
#import "CXmppRequestMgr.h"
#import "UIUtil.h"
#import "CHChatRoomBase.h"
#import "RedPacketInfo.h"
@interface selfSendRedPacketViewController ()
@property(nonatomic,strong)CContactModel *currentUser;
@end

@implementation selfSendRedPacketViewController
-(CContactModel *)currentUser
{
    if (_currentUser == nil) {
        _currentUser = [[[CContactMgr alloc]init] loadCurContact];
    }
    return _currentUser;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self.navigationItem setNewTitleCenter:@"红包详情"];
     self.view.backgroundColor = RGBCOLOR(240, 240, 240);
    if (IsIOS7) {
        [self.navigationController.navigationBar setBarTintColor:RGBCOLOR(246, 75, 77)];
    }
    else
    {
        [self.navigationController.navigationBar setTintColor:RGBCOLOR(246, 75, 77)];
    }

}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self configInterFace];
}
-(void)configInterFace
{
    UIView *topView = [[UIView alloc]init];
    topView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:topView];
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(0);
        make.height.mas_equalTo(250);
    }];
    UILabel *timeLabel = [[UILabel alloc]init];
    timeLabel.font = [UIFont systemFontOfSize:13];
    timeLabel.textColor = RGBCOLORWITH16COLOR(0xaaaaaa);
    timeLabel.textAlignment = NSTextAlignmentLeft;
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:[self.time doubleValue] / 1000.0];
    NSString *str1 = [UIUtil getOverdueYMDHMSDateStringWithTimeStamp:date];
    NSString *str2 = [UIUtil timeForMessageStyle:date];
    timeLabel.text = [NSString stringWithFormat:@"%@ %@",str1,str2];
    [topView addSubview:timeLabel];
    [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.top.mas_equalTo(0);
        make.left.mas_equalTo(5);
        make.height.mas_equalTo(30);
    }];
    UIImageView *imageView = [[UIImageView alloc]init];
    [imageView sd_setImageWithURL:[NSURL URLWithString:[[CXmppRequestMgr shareInstance] DownHeadFileWithContact:self.currentUser.UserID]] placeholderImage:[UIImage imageNamed:@"testHeader"]];
    imageView.layer.cornerRadius = 40;
    imageView.layer.masksToBounds = YES;
    [topView addSubview:imageView];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(timeLabel.mas_bottom).offset(10);
        make.width.height.mas_equalTo(80);
        make.centerX.mas_equalTo(topView);
    }];
    UILabel *nameLable = [[UILabel alloc]init];
    nameLable.textColor = RGBCOLORWITH16COLOR(0x323232);
    nameLable.text = self.currentUser.UserName;
    nameLable.font = [UIFont systemFontOfSize:15];
    nameLable.textAlignment = NSTextAlignmentCenter;
    [topView addSubview:nameLable];
    [nameLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(imageView.mas_bottom).offset(20);
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(30);
    }];
    UILabel *contentLable = [[UILabel alloc]init];
    contentLable.font = [UIFont systemFontOfSize:20];
    contentLable.textAlignment = NSTextAlignmentCenter;
    contentLable.text = @"送你一个红包";
    contentLable.textColor = RGBCOLORWITH16COLOR(0xaaaaaa);
    [topView addSubview:contentLable];
    [contentLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(nameLable.mas_bottom).offset(0);
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(40);
    }];
    UILabel *infoLabel = [[UILabel alloc]init];
    infoLabel.font = [UIFont systemFontOfSize:13];
    infoLabel.textColor = RGBCOLORWITH16COLOR(0xaaaaaa);
    infoLabel.textAlignment = NSTextAlignmentLeft;
    infoLabel.text = [NSString stringWithFormat:@"共%.2f元，发出一个红包",self.redinfo.money];
    [self.view addSubview:infoLabel];
    [infoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(10);
        make.width.mas_offset(200);
        make.top.equalTo(topView.mas_bottom).offset(0);
        make.height.mas_equalTo(30);
    }];
        UILabel *statusLabel = [[UILabel alloc]init];
        statusLabel.font = [UIFont systemFontOfSize:13];
        statusLabel.textColor = RGBCOLORWITH16COLOR(0xefa811);
        statusLabel.textAlignment = NSTextAlignmentLeft;
        statusLabel.text = self.redinfo.robed?@"对方已领取":@"等待对方领取";
        [self.view addSubview:statusLabel];
        [statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(0);
            make.height.mas_equalTo(30);
            make.top.equalTo(topView.mas_bottom).offset(0);
            make.left.equalTo(infoLabel.mas_right).offset(0);
        }];

}
@end
